package com.lei.zjs.service.ebo;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lei.zjs.dao.FunctionDao;
import com.lei.zjs.service.ebi.FunctionService;
import com.lei.zjs.utils.BOSContext;
import com.lei.zjs.vo.Function;
import com.lei.zjs.vo.User;

@Service
@Transactional
public class FunctionServiceImpl implements FunctionService{

	@Resource
	private FunctionDao functionDao;

	@Override
	public List<Function> findAll() {
		return functionDao.findAll();
	}

	@Override
	public void save(Function model) {
		functionDao.save(model);
	}

	@Override
	public List<Function> findMenu(User user) {
		List<Function> list = null;
		if ("admin".equals(user.getUsername())) {
			//超级管理员,应该加载所有菜单
			list = functionDao.findMenu();
		}else{
			list = functionDao.findMenuByUser(user.getId());
		}
		return list;
	}
}
